R for Lunch

Reproducible workflows

John Little

Center for Data & Visualization Sciences

Duke University Libraries

2024-02-19

Today’s topics



You should have the latest version of Quarto!!

Reproducibility


What is a reproducible workflow and why does it matter?

Streaming previous workshops

R for Lunch: a lunchtime learning series


See Also: Online Resources: (Rfun | CDVS resources)

Housekeeping

  • Drew / Lauren / breakout rooms
  • CDVS
    • Themes
      • Data Management (Plans, Reproducibility, Repositories)

      • Data Science

      • Data Visualization

      • GIS and Spatial Analysis

      • Data Sources

Housekeeping continued

Ideal: R as a practical reproducible workflow

Reproducibility settings for your IDE

Global options > Code ^^
<- Global options > General

Publish

  • Full Instructions

  • Steps (simplified)

    1. In CLI (terminal, powershell, bash, etc.): quarto publish (For select Quarto project types)

    2. Choose a destination (e.g. quarto.pub or netlify.com)

Manuscript demo


Instructions simplified

  1. In CLI (e.g. RStudio Terminal, PowerShell, Bash, etc.):
    quarto create > project > manuscript
    • Identify LFS path / location
  2. Go to that location; double-click <new_proj_name>.Rproj file (if using R)
  3. useths::use_git()
  4. in _quarto.yml: change jats: default to pdf: default

{renv}


Create reproducible environments for your R projects


  • Get Started
    • renv::init()
    • renv::snapshot()
    • and renv::restore()

Binder (Containers)


The Binder project makes it easy to share compute environments. This is documented very well at Quarto.

In essence:

  • CLI terminal: quarto use binder

Polls

We are here to help

  • askData@duke.edu

  • https://library.duke.edu/data

  • https://is.gd/littleconsult

Let’s do it

Two things for today

Exercises

  1. https://intro2r.library.duke.edu/ > Exercises > Link out > Green Code button > Download ZIP

  2. Then, Unzip (i.e. Expand) the folder (on your local file system)

  3. Then, double click the rforlunch_exercises.Rproj file

  4. From RStudio the Files tab, open the 01_dplyr.qmd

    • The answer file is in the RStudio rforlunch_exercises project > Files Tab > Answers folder

Closing

Citation management

Where to find

 

RStudio > Quarto Notebook > Insert > Citation

Example DOI: 10.18637/jss.v059.i10

Bye for now